package com.vfa.file;



import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.vfa.vocaburay.R;

public class ListArrayAdapter extends ArrayAdapter<FileInfo> {
	
	private LayoutInflater mInflater;	
	
	private int mViewResourceId;
	
	private List<FileInfo> mFileInfo = new ArrayList<FileInfo>();
	
	public ListArrayAdapter(Context context,int viewResourceId, List<FileInfo> fileInfos){
		super(context, viewResourceId);
		
		mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mViewResourceId = viewResourceId;
		mFileInfo = fileInfos;
	}

	@Override
	public int getCount() {
		return mFileInfo.size();
	}

	@Override
	public FileInfo getItem(int position) {
		return mFileInfo.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(mViewResourceId, null);
		
		ImageView iv = (ImageView)convertView.findViewById(R.id.img);
		iv.setImageResource(mFileInfo.get(position).mFileImageType);
		
		TextView tv1 = (TextView)convertView.findViewById(R.id.title);
		tv1.setText(mFileInfo.get(position).mFileName);
		
		TextView tv2 = (TextView)convertView.findViewById(R.id.detail);
		tv2.setText(mFileInfo.get(position).mFileCount);
		
		return convertView;
	}
}
